<div style="width: 100%; height: 100%; overflow-y:auto">
<div class="step1">
    <div class="important">
        <span class="f">!</span>请先转账成功后再点“下一步”按钮提交存款信息！
    </div>

    <div class="charge_item banklist">
        <select data-am-selected class="am-form-field">
        </select>
    </div>

    <div class="bankinfo">
    </div>

    <div class="button2 bank">
        <button type="button" class="am-btn am-btn-primary btn-save">下一步</button>
    </div>
</div>

<div class="step2" style="display: none;">
    <div class="charge_item amount">
        <input type="number" class="am-form-field" placeholder="请填写存款金额" />
    </div>
    <div class="clue">
        单笔下限<span class="red min">10</span>，单笔上限<span class="red max">9999999</span>
    </div>

    <div class="common_container">
        <div class="charge_item name">
            <input type="text" class="am-form-field" placeholder="请填写实际转账人姓名" />
        </div>

        <div class="charge_item time">
            <input type="text" value="" class="am-form-field" placeholder="" data-am-datepicker readonly />
        </div>
    </div>

    <div class="button2 bank">
        <button type="button" class="am-btn am-btn-primary btn-save">提交</button>
    </div>
</div>

<div class="step3" style="display: none">
    <div class="important">
        <span class="f">!</span>为了加快入款速度，请务必于转账后再提交资料！
    </div>
    <div class="charge-title">存款信息</div>
    <div class="charge_info">
        <div class="c1">存入金额：<span class="red">0.00</span></div>
        <div class="c2">用户姓名：<span></span></div>
        <div class="c3">存款时间：<span></span></div>
        <div class="c4">存款方式：<span>银行转账</span></div>
        <div class="c5">备 注 码：<span></span></div>
    </div>
    <div class="charge-title">银行信息</div>
    <div class="bank_info">
        <div class="c1">开户银行：<span></span></div>
        <div class="c2">开户网点：<span></span></div>
        <div class="c3">开户姓名：<span></span></div>
        <div class="c4">银行卡号：<span></span></div>
    </div>

    <div class="button2 bank">
        <button type="button" class="am-btn am-btn-primary btn-save">提交申请</button>
    </div>
</div>
</div>

<style type="text/css">
.step1, .step2, .step3 {
    padding: 10px;
    font-size: 0.6rem;
}
</style>

<script>
    $("#center-top .home").hide();
    $("#center-top .back").show();
    $("#center-top .menu").hide();
    $("#center-top .back2game").show();

    $("#clue2 #clue2_content").html("转账时在“备注”处填写备注码和账号名称，提交订单后才能秒到！备注码是4位数，不要填写中文。");
    $("#clue2").modal({
        width: 250
    });

    // 生成付款码
    var code = '';
    for (var i = 0; i < 4; i++)
        code += '' + parseInt(Math.random() * 10);
    
    var currStep = 1;
    $(".step1 button").click(function() {
        currStep = 2;
        $(".step1").hide();
        $(".step2").show();
        $(".step3").hide();
    });

    var banks = [];
    ME.query(function() {
        Classify.queryExt("money", "banks", true, [], function(r) {
            var grade = context.user.user.layer || 0;
            grade = grade + '';
            for (var i in r) {
                if (r[i].enable != 1) continue;
                if (r[i].layer.indexOf(grade) == -1) continue;
                banks.push(r[i]);
            }
            banks.sort(function(a, b) {
                return (b.sort || 0) - (a.sort || 0);
            });
            
            // 填充银行列表
            var list = $(".banklist select");
            list.empty();
            for (var i in banks) {
                var bank = banks[i];
                if (bank.enable != 1) continue;
                list.append('<option value="' + bank.bank + '">' + bank.bank + '</option>');
            }
            fillBankInfo();
        });
    });
    
    function fillBankInfo() {
        var b = $(".banklist select").val();
        var bank;
        for (var i in banks) {
            if (banks[i].bank == b) {
                bank = banks[i];
                break;
            }
        }
        if (!bank) return;
        $(".bankinfo").empty();
        $(".bankinfo").append('<div class="item"><div class="title">银行名称：</div>' +
            '<div class="v">' + bank.bank + '</div></div>');
        $(".bankinfo").append('<div class="item"><div class="title">收 款 人：</div>' +
            '<div class="v">' + bank.name + '</div></div>');
        $(".bankinfo").append('<div class="item"><div class="title">开户网点：</div>' +
            '<div class="v">' + bank.addr + '</div></div>');
        $(".bankinfo").append('<div class="item"><div class="title">银行账号：</div>' +
            '<div class="v">' + bank.account + '</div></div>');
        $(".bankinfo").append('<div class="item"><div class="title">备 注 码：</div>' +
            '<div class="v" style="color:red; font-weight:bold;">' + code + '</div></div>');

        $("span.min").html(bank.min || 0);
        $("span.max").html(bank.max || 0);
    }
    $(".banklist select").change(fillBankInfo);
    $(function() {
        $(".time input").datetimepicker({
            format: "yyyy-mm-dd hh:ii:ss"
        });
        $(".time input").val(new Date().Format("yyyy-MM-dd HH:mm:ss"));
    });

    $(".step2 button").click(function() {
        var amount = $(".amount input").val().trim();
        if (amount == '' || parseInt(amount) < parseInt($("span.min").html()) || 
            parseInt(amount) > parseInt($("span.max").html())) {
            alert2("金额不对！");
            return;
        }

        var b = $(".banklist select").val();
        var bank;
        for (var i in banks) {
            if (banks[i].bank == b) {
                bank = banks[i];
                break;
            }
        }
        if (!bank) return;

        var name = $(".name input").val();
        if (!name) {
            alert2("请填写转账人姓名！");
            return;
        }

        // 进入第三步
        currStep = 3;
        $(".step1").hide();
        $(".step2").hide();
        $(".step3").show();

        $(".step3 .charge_info .c1 span").html(amount);
        $(".step3 .charge_info .c2 span").html(name);
        $(".step3 .charge_info .c3 span").html($(".time input").val());
        $(".step3 .bank_info .c1 span").html(bank.bank);
        $(".step3 .bank_info .c2 span").html(bank.addr);
        $(".step3 .bank_info .c3 span").html(bank.name);
        $(".step3 .bank_info .c4 span").html(bank.account);
        $(".step3 .charge_info .c5 span").html(code);
    });
    $(".step3 button").click(function() {
        var amount = $(".amount input").val().trim();
        var b = $(".banklist select").val();
        var name = $(".name input").val();
        var time = $(".time input").val();
        var bank;
        for (var i in banks) {
            if (banks[i].bank == b) {
                bank = banks[i];
                break;
            }
        }

        var memo = {
            time: time,
            bank: bank.bank,
            name: bank.name,
            account: bank.account,
            requestAccount: name,
            code: code,
        };
        startLoading();
        CMD.deposit(null, "", amount * 100, "handOper", "bank", memo, function(r) {
            stopLoading();
            if (r.message) {
                alert2(r.message);
                return;
            }
            alert2("提交请求成功，请等待客服审核");

            setTimeout(function() {
                Util.jumpUrl({
                    cmd: 'charge'
                });
            }, 1500);
        })
    });

</script>